<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ page import="com.gouwudai.gobbs.pojo.TbbsUserInfo,com.gouwudai.gobbs.pojo.TbbsTopic"%>
<%@ include file="../common/common.jsp" %>
<%@ include file="user_pass2.jsp" %>
<%
int topicId = ParamUtils.getIntParameter(request,"topicId");

/***************** 权限验证模块 START *********************/
ITopicService topicService = (ITopicService)BeanManager.getBean("topicService");
TbbsTopic tbbsTopic = null;

//1.判断当前版面是否存在
try
{
	tbbsTopic = topicService.load(new Integer(topicId));	
}
catch(Exception e)
{
	HtmlConst.errors(out,7,"您浏览的主题不存在或已被删除！");
	return;
}
/***************** 权限验证模块 END *********************/
String topicUrl = SYSINFO.getSysUrl()+"club/topic_page.jsp?classId="+tbbsTopic.getClassId()+"&topicId="+topicId;	//邮件中主题的链接

String mailFrom = userLogin.getEmail();
String loginId = LOGIN_ID;
String userName = USER_NAME;
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><%=SYSTITLE%> - 推荐文章</title>
<meta name="Keywords" content="<%=SYSMETAKEY%>" />
<meta name="Description" content="<%=SYSMETADESC%>" />
<%@ include file="../common/meta.inc" %>
<link rel="stylesheet" type="text/css" href="css/defaultStyle.css" >
<script language="javascript" src="${pageContext.request.contextPath}/scripts/prototype.js"></script>
<script language="javascript" src="${pageContext.request.contextPath}/scripts/buffalo/buffalo.js"></script>
</head>
<body>
<%@ include file="../common/waiting.inc" %>
<SCRIPT language="javascript">

setStatus('<%=SYSTITLE%> - 推荐文章');

var END_POINT="${pageContext.request.contextPath}/buffalo";
var buffalo = new Buffalo(END_POINT);
function doSubmit()
{
	form = document.theform;
	if(!validateForm(form))
		return false;
		
    var obj = {};    
    
	obj[Buffalo.BOCLASS] = "java.util.HashMap";
	
	obj.mailFrom = "<%=mailFrom%>";
	obj.mailSign = "<%=userName%>(<%=loginId%>)";
	obj.mailTo = $F('mailTo');
	obj.ttitle =  $F('ttitle');
	obj.tcontent =  $F('tcontent');	
	
    buffalo.remoteCall("emailServiceAjaxService.topicSend",[obj], function(reply) 
    {
        var ret = reply.getResult();
       	ajaxSubmit(ret,"邮件已发送！","close");        
    }); 
}

function validateForm(form)
{	
	if(!sl_checkEmail(form.mailTo,"收件人")) return false; 
	if(!sl_check(form.ttitle,"主题",100,1)) return false; 
	if(!sl_checkNull(form.tcontent,"内容")) return false; 
	return true;
}
</SCRIPT>
<script language="javascript" type="text/javascript" src="template/scripts/topBar.js"></script>
<DIV class="line"></DIV>
<DIV class="list_table_0"><%=HtmlConst.navMenuNoLink("推荐文章")%></DIV>
<DIV class="line"></DIV>
<form name="theform" id="theform" method="post" onSubmit="return validateForm(this);">
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" class="tab">
<tr class="tab2">
<td width="100"><strong>收件人</strong></td>
<td height="22"><input type="text" id="mailTo" name="mailTo" size="20"></td>
</tr>
<tr class="tab2">
<td height="25"><strong>回复地址</strong></td>
<td>
<span class="style1"><%=userLogin.getEmail()%></span>
</td>
</tr>
<tr class="tab2">
<td height="12"><strong>主题</strong></td>
<td><input type="text" id="ttitle" name="ttitle" value="推荐文章" size="20"></td>
</tr>
<tr class="tab2">
<td height="12"><strong>内容</strong></td>
<td><textarea id="tcontent" name="tcontent" cols="60" rows="8">
我在<%=SYSNAME%>论坛发现了一篇很棒的帖子
帖子主题是：
点击下面的链接可以查看详细内容：
<a href="<%=topicUrl%>"><%=topicUrl%></a>
</textarea></td>
</tr>
<tr class="tab2">
<td height="25">&nbsp;</td>
<td>
	<button id="btnSubmit" name="btnSubmit" class="btn" onClick="doSubmit();">确定</button>&nbsp;&nbsp;&nbsp;
	<button id="btnBack" name="btnBack" class="btn" onClick="history.back();">返回</button></td>
</tr>
</table>
</form>
<%=COPYRIGHTFOOT%>
<%@ include file="../common/foot.inc"%>
</body>
</html>